/**
 * Created by huangchao on 20/11/2017.
 */
import {
  CLIENT_DEFULATE_DATA_LIST,
} from '../actions/clientSystem'

const initalData = {
  loading: false,
  list: [],
  count: {
    notPassCount: 0,
    notaCount: 0,
    auditedCount: 0,
    passCount: 0,
    customerCount: 0,
  },
  page: {
    pageNum: 1,
    pageSize: 10,
    total: '',
  },
  columns: [{
    title: '客户编号',
    dataIndex: 'number',
    checked: true,
    key: 1,
  }, {
    title: '客户姓名',
    dataIndex: 'name',
    checked: true,
    key: 2,
  }, {
    title: '客户类型',
    dataIndex: 'cType',
    checked: true,
    key: 3,
  }, {
    title: '审核状态',
    dataIndex: 'sta',
    checked: true,
    key: 4,
  }, {
    title: '提交时间',
    dataIndex: 'createTime',
    checked: true,
    key: 5,
  }, {
    title: '修改时间',
    dataIndex: 'modifyTime',
    checked: true,
    key: 6,
  }, {
    title: '操作',
    dataIndex: 'action',
    checked: true,
    key: 7,
  }, {
    title: 'test1',
    dataIndex: 'action',
    checked: false,
    key: 8,
  }, {
    title: 'test2',
    dataIndex: 'action',
    checked: false,
    key: 9,
  }],
}

export default (state = initalData, action = {}) => {
  switch (action.type) {
    case CLIENT_DEFULATE_DATA_LIST: // 基本搜索
      console.log(action)
      return {
        ...state,
        list: action.data.data.data.map(data => {
          console.log(data)
          return {
            ...data,
            key: data.id,
          }
        }),
        page: {
          ...action.data.data.page,
          pageNum: action.args.pageNum,
          pageSize: action.args.pageSize,
        },
      }
    default:
      return state
  }
}
